﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StrategyForm.cs" company="">
//   
// </copyright>
// <summary>
//   The strategy form.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


using System;
using System.Data.Objects;
using System.Windows.Forms;
using Systemathics.FrameWork;

namespace Systemathics.UserControls.Chart
{
    public partial class StrategyForm : Form
    {
        public StrategyForm()
        {
            InitializeComponent();

            using (var db = new SystemathicsEntities(GlobalVariables.EntitiesConnectionString()))
                StrategyGrid.DataSource = db.DBStrategies.Execute(MergeOption.AppendOnly);
        }

        public Guid Id { get; private set; }
        public String Name { get; private set; }
        public String Info { get; private set; }
        public String Pattern { get; private set; }
        public String Version { get; private set; }
        public DateTime CreationDate { get; private set; }


        private void StrategyGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                Id = new Guid(StrategyGrid["ID", e.RowIndex].Value.ToString());
                Name = StrategyGrid["Name_", e.RowIndex].Value.ToString();
                Name = StrategyGrid["Info_", e.RowIndex].Value.ToString();
                Pattern = StrategyGrid["Pattern_", e.RowIndex].Value.ToString();
                Version = StrategyGrid["Version_", e.RowIndex].Value.ToString();
                CreationDate = (DateTime)StrategyGrid["CreationDate_", e.RowIndex].Value;

                DialogResult = DialogResult.OK;
            }
        }
    }
}